package com.insea.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

@Entity
public class Acte extends BaseObject{

	private Long id;
	private String numActe;
	private String tarifActe;
	private String nomCommunActe;
	private String abrevNomActe;
	private FamilleActe familleActe;
	private boolean coche;


	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "numActe")
	public String getNumActe() {
		return this.numActe;
	}

	public void setNumActe(String numActe) {
		this.numActe = numActe;
	}

	@Column(name = "tarifActe")
	public String getTarifActe() {
		return this.tarifActe;
	}

	public void setTarifActe(String tarifActe) {
		this.tarifActe = tarifActe;
	}

	@Column(name = "nomCommunActe")
	public String getNomCommunActe() {
		return this.nomCommunActe;
	}

	public void setNomCommunActe(String nomCommunActe) {
		this.nomCommunActe = nomCommunActe;
	}

	@Column(name="abrevNomActe", unique=true)
	public String getAbrevNomActe() {
		return abrevNomActe;
	}

	public void setAbrevNomActe(String abrevNomActe) {
		this.abrevNomActe = abrevNomActe;
	}

	@ManyToOne
    @JoinColumn(name="FAMILLE_ACTE_ID")
	public FamilleActe getFamilleActe() {
		return familleActe;
	}

	public void setFamilleActe(FamilleActe familleActe) {
		this.familleActe = familleActe;
	}
	
	@Transient
	public boolean isCoche() {
		return coche;
	}

	public void setCoche(boolean coche) {
		this.coche = coche;
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof Acte))
			return false;
		Acte castOther = (Acte) other;

		return ((this.getNumActe() == castOther.getNumActe()) || (this
				.getNumActe() != null && castOther.getNumActe() != null && this
				.getNumActe().equals(castOther.getNumActe())))
				&& ((this.getTarifActe() == castOther.getTarifActe()) || (this
						.getTarifActe() != null
						&& castOther.getTarifActe() != null && this
						.getTarifActe().equals(castOther.getTarifActe())))
				&& ((this.getNomCommunActe() == castOther.getNomCommunActe()) || (this
						.getNomCommunActe() != null
						&& castOther.getNomCommunActe() != null && this
						.getNomCommunActe()
						.equals(castOther.getNomCommunActe())));
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result
				+ (getNumActe() == null ? 0 : this.getNumActe().hashCode());
		result = 37 * result
				+ (getTarifActe() == null ? 0 : this.getTarifActe().hashCode());
		result = 37
				* result
				+ (getNomCommunActe() == null ? 0 : this.getNomCommunActe()
						.hashCode());
		return result;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
}
